Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add callbacks for async chaining of tasks #1822

Closed
wants to merge 3 commits into from
Closed

add callbacks for async chaining of tasks #1822

wants to merge 3 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Nov 4, 2011

Right now, you're kind of screwed if you need to use async code in a subtask from cake. This branch adds an extra callback argument to invoke so that you can supply a completion callback to an asynchronous subtask.

@michaelficarra
Copy link
Collaborator

You'll need to modify /src/cake.coffee as well...

@ghost
Copy link
Author

ghost commented Nov 4, 2011

Oh, I'm an idiot. Yes.

@ghost
Copy link
Author

ghost commented Nov 4, 2011

All right, updated both the .coffee and the .js now.

@ghost
Copy link
Author

ghost commented Nov 4, 2011

I'm not sure this works as a solution, actually -- as long as there are existing invoke() calls that don't supply a callback, then it's still kind of a mess.

@jashkenas
Copy link
Owner

So, here's the deal with Cake -- it's just a tiny little shim for exposing your top-level CoffeeScript functions to the command-line:

http://jashkenas.github.com/coffee-script/documentation/docs/cake.html

... not a full-featured Rake-style library with dependency resolution, nested tasks, etc etc. The idea is that those things: composing multiple async events, determining the order in which a series of functions should be run, defining a complex API -- are all things better done in regular code, and not a wimpy DSL. Once you have your code sorted out, instead of stuffing all of the important reusable logic into Cake tasks, just expose the bits you want accessible to the command-line via Cake. Does that sound reasonable?

@ghost
Copy link
Author

ghost commented Nov 4, 2011

Yeah, I think that's pretty much how it has to work. Callbacks are pretty much an all-or-nothing thing in node. Node fail rather than cake fail I guess.

@ghost ghost closed this Nov 4, 2011
@devongovett devongovett mentioned this pull request Dec 18, 2011
@focusaurus
Copy link

Jeremy (or anyone who knows...), could you post an example of how to invoke a module that does async stuff from a Cakefile? I've tried code both in the Cakefile and in a separate .coffee module required by the Cakefile and either way my main process exits before my async code is done executing. I'm trying to use child_process.spawn to launch mocha tests.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants